n, m = map(int, input().split(" "))

g = [[0 for i in range(m)] for i in range(n)]
f = [[[0 for i in range(m + 1)] for i in range(m + 1)] for i in range(n + 1)]
qmi = [0 for i in range(81)]

for i in range(n):
    g[i] = list(map(int, input().split(" ")))

qmi[0] = 1
for i in range(1, 81):
    qmi[i] = qmi[i - 1] * 2

for k in range(n):
    for len in range(m - 1, 0, -1):
        
        for i in range(m):
            if i + len - 1 < m:
                j = i + len - 1
                if i == 0:
                    f[k][i][j] = f[k][i][j + 1] + g[k][j + 1] * qmi[m - len]
                elif j == (m - 1):
                    f[k][i][j] = f[k][i - 1][j] + g[k][i - 1] * qmi[m - len]
                else:
                    f[k][i][j] = max(f[k][i][j + 1] + g[k][j + 1] * qmi[m - len], f[k][i - 1][j] + g[k][i - 1] * qmi[m - len])
            else:
                break


res = 0

for k in range(n):
    temp = 0
    for i in range(m):
        temp = max(temp, f[k][i][i] + g[k][i] * qmi[m])
    res += temp

print(res)